package com.lagou.controller;

import com.lagou.pojo.Article;
import com.lagou.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author srh
 * @date 2020/05/04
 **/
@Controller
public class IndexController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping(value = "/")
    public String index() {
        return "login";
    }

    @RequestMapping(value = "toResult")
    public ModelAndView toResult(ModelAndView mv) {
        Page<Article> articles = articleService.queryPage(ArticleService.DEFAULT_PAGE);
        mv.addObject("list", articles.getContent());
        mv.setViewName("result");
        return mv;
    }

}
